using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace Krilib.Bridges
{
    public interface IMainForm
    {
        /// <summary>
        /// Add tab to main form
        /// </summary>
        void AddTab();

        /// <summary>
        /// Add tab to main form
        /// </summary>
        /// <param name="name">tab name</param>
        /// <param name="cluster">tab clusters</param>
        /// <param name="serviceIds">linking service ids(this use for input select on initialize)</param>
        void AddTab(string name, Data.SearchDataCluster cluster, string[] serviceIds);

        void AddPluginMenu(Plugin.IPlugin plugin, ToolStripMenuItem menuitem);

        void AddCustomContextMenuCandidate(CustomContextMenuCandidate candidate);

        void SetStatusText(string text);

        void SetStatusText(string text, int showlen);

        void SetBackStatusText(string text, bool keepalive);

        Data.Status SelectedStatus { get; }

        void RefreshTL(bool remeasure);

        void RefreshTLWeak();

        void EnsureVisible();

        IInputControlManager InputControlManager { get; }
    }

    public abstract class CustomContextMenuCandidate
    {
        public abstract ToolStripMenuItem GetMenuItem();

        public abstract bool IsShowMenu(Data.Status selected);
    }

    public interface IInputControlManager
    {
        /// <summary>
        /// Set in reply to uid
        /// </summary>
        /// <remarks>
        /// If you set zero to uid,it calls ClearReplyTo() method.
        /// </remarks>
        /// <param name="uid">Message uid</param>
        void SetReplyTo(ulong uid);

        /// <summary>
        /// initialize replying state
        /// </summary>
        void ClearReplyTo();

        /// <summary>
        /// Examine current input method's type
        /// </summary>
        /// <param name="type">test type</param>
        /// <returns>equals=true</returns>
        bool CheckCurInputMethodIs(Type type);

        /// <summary>
        /// Get current input method's id.
        /// </summary>
        /// <param name="id">examine id</param>
        /// <remarks>
        /// If I haven't any method now, I always return false.
        /// </remarks>
        bool CheckCurInputMethodIs(string id);

        /// <summary>
        /// Check existing current input method
        /// </summary>
        /// <returns></returns>
        bool IsCurInputMethodExisted();

        /// <summary>
        /// Overwrite input text
        /// </summary>
        /// <param name="text">set text</param>
        void SetInputText(string text);

        /// <summary>
        /// Overwrite input text
        /// </summary>
        /// <param name="text">set text</param>
        /// <param name="raiseInvalidOperationException">if internal input method reference is null, I raise it.</param>
        void SetInputText(string text, bool raiseInvalidOperationException);

        /// <summary>
        /// Get current inputted text
        /// </summary>
        /// <returns></returns>
        string GetInputText();

        /// <summary>
        /// Set extra data to current input method
        /// </summary>
        /// <remarks>
        /// For security reason, I set this prop only when id matches current method's id.
        /// You should examine current id before call this method.
        /// </remarks>
        /// <param name="id"></param>
        /// <param name="extraData"></param>
        void SetExtraData(string id, object extraData);
    }
}
